package com.auxgroup.hr.front.service.hireperson.impl;

import java.sql.Timestamp;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import com.auxgroup.hr.front.commons.utils.ObjectFieldUtils;
import com.auxgroup.hr.front.dao.domain.PsCHireTactPer;
import com.auxgroup.hr.front.dao.repository.PsCHireTactPerRepository;
import com.auxgroup.hr.front.service.hireperson.HireTactPerService;

/** 
 * @author lvliuhao
 * @version 创建时间：180523 
 * 入职人员家庭情况service
 */
@Service("hireTactPerService")
public class HireTactPerServiceImpl implements HireTactPerService {
	private static final Logger logger = LoggerFactory.getLogger(HireEducatServiceImpl.class);
	
	@Autowired
	private PsCHireTactPerRepository PsCHireTactPerRepository;


	@Override
	public PsCHireTactPer getHireTactPer(String  rsHireID) {
		return PsCHireTactPerRepository.findOne(rsHireID);
	}


	@Override
	public PsCHireTactPer save(PsCHireTactPer HireTactPer) {
		HireTactPer.setHrsRowAddDttm(new Timestamp(System.currentTimeMillis()));
		HireTactPer.setHrsRowAddOprid(HireTactPer.getRsHireId());
		HireTactPer.setHrsRowUpdOprid(HireTactPer.getRsHireId());
		HireTactPer.setHrsRowUpdDttm(new Timestamp(System.currentTimeMillis()));
		ObjectFieldUtils.handleNullValue(HireTactPer);
		return PsCHireTactPerRepository.save(HireTactPer);
	}


	@Override
	public Boolean delete(String  rsHireID) {
		try {
			PsCHireTactPerRepository.delete(rsHireID);
		} catch (Exception e) {
			logger.error("delete HireTactPer error: hirePrimary={}",rsHireID,e);
			return false;
		}
		return true;
	}
	
	
	@Override
	public List<PsCHireTactPer> getAll(String rsHireId) {
		PsCHireTactPer HireTactPer = new PsCHireTactPer();
		HireTactPer.setRsHireId(rsHireId);
		return PsCHireTactPerRepository.findAll(Example.of(HireTactPer));
	}


	
	
	
}
